package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.ExtIotScene;
import com.econ.powercloud.ems.dal.mapper.ExtIotSceneMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author : zjf
 * @Description :
 * @Date : 2022/2/18 8:54
 * @Modified by : zjf
 */
@Repository
public class ExtIotSceneDAO extends ServiceImpl<ExtIotSceneMapper, ExtIotScene> {

    public ExtIotScene selectBySceneCodeAndApplicationCode(String sceneCode, String applicationCode) {
        LambdaQueryWrapper<ExtIotScene> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StringUtils.isNotBlank(sceneCode), ExtIotScene::getSceneCode,sceneCode);
        wrapper.eq(StringUtils.isNotBlank(applicationCode), ExtIotScene::getApplicationCode,applicationCode);
        wrapper.last("limit 1");
        return this.baseMapper.selectOne(wrapper);
    }
}
